﻿//-----------------------------------------------------------------------
// <copyright file="Copyright.cs" author="Michael Herndon">
//     Copyright (c) Company.  All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace Amplify.CodeDom
{
	using System;
	using System.Collections;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;

	internal static class InternalMixin
	{

		public static object Find(this IList list, Predicate<object> predicate)
		{
			foreach (object item in list)
				if (predicate(item))
					return item;
			return null;
		}

		public static T Find<T>(this IList list, Predicate<T> predicate)
		{
			foreach (T item in list)
				if (predicate(item))
					return item;
			return default(T);
		}

		public static void Each(this IList list, Action<object> action)
		{
			foreach (object item in list)
				action(item);
		}

		public static void Each<T>(this IList list, Action<T> action)
		{
			foreach (T item in list)
				action(item);
		}

		public static void Each<T>(this IEnumerable<T> items, Action<T> action)
		{
			foreach (T item in items)
				action(item);
		}

		public static string ToFieldName(this string unit)
		{
			return Template.Modifier + unit.Camelize();
		}

		public static string Camelize(this string unit)
		{
			return unit[0].ToString().ToLower() + unit.Substring(1);
		}


	}
}
